package mrms.api.entity;

import lombok.ToString;

import javax.persistence.*;
import java.util.Arrays;
import java.util.Objects;
@ToString
@Entity
@Table(name = "user", schema = "mrms", catalog = "")
public class UserEntity {
    private String id;
    private String name;
    private String password;
    private String email;
    private String tel;
    private DeptEntity dept;
    private Integer permission;
    private byte[] feature;
    private String faceuri;
    private String newface;
    private Integer enabled;

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "tel")
    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @ManyToOne(targetEntity = DeptEntity.class)
    @JoinColumn(name = "dept")
    public DeptEntity getDept() {
        return dept;
    }

    public void setDept(DeptEntity dept) {
        this.dept = dept;
    }

    @Basic
    @Column(name = "permission")
    public Integer getPermission() {
        return permission;
    }

    public void setPermission(Integer permission) {
        this.permission = permission;
    }

    @Basic
    @Column(name = "feature")
    public byte[] getFeature() {
        return feature;
    }

    public void setFeature(byte[] feature) {
        this.feature = feature;
    }

    @Basic
    @Column(name = "faceuri")
    public String getFaceuri() {
        return faceuri;
    }

    public void setFaceuri(String faceuri) {
        this.faceuri = faceuri;
    }

    @Basic
    @Column(name = "newface")
    public String getNewface() {
        return newface;
    }

    public void setNewface(String newface) {
        this.newface = newface;
    }

    @Basic
    @Column(name = "enabled")
    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserEntity that = (UserEntity) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(name, that.name) &&
                Objects.equals(password, that.password) &&
                Objects.equals(email, that.email) &&
                Objects.equals(tel, that.tel) &&
                Objects.equals(dept, that.dept) &&
                Objects.equals(permission, that.permission) &&
                Arrays.equals(feature, that.feature) &&
                Objects.equals(faceuri, that.faceuri) &&
                Objects.equals(newface, that.newface) &&
                Objects.equals(enabled, that.enabled);
    }

    @Override
    public int hashCode() {

        int result = Objects.hash(id, name, password, email, tel, dept, permission, faceuri, newface, enabled);
        result = 31 * result + Arrays.hashCode(feature);
        return result;
    }
}
